home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STRDUP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  332 b   |  15 lines

  1. /* strdup.c From TC Bible page 281  Use strdup to allocate
  2.  memory and copy a given string into that space */
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6. main()
  7. {
  8.     char str1[80], *str1_copy;
  9.     printf("Enter a string: ");
  10.     gets(str1);
  11.     str1_copy = strdup(str1);
  12.     printf("String duplicated. Result is: %s\n", str1_copy);
  13.  
  14. }
  15.